package com;

public class People {
    public String name;
    private int age;
    public String sex;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws MyException{
        if (age < 0 || age > 100) {
            throw new MyException("年龄不合法");
        }
        System.out.println("年龄合法");
        this.age = age;
    }
}
